<?php $this->_extends('_layouts/default_layout'); ?>

<?php $this->_block('contents'); ?>


<span><a href="<?php echo url('user/AddMember'); ?>">企业用户添加</a> | <a href="<?php echo url('user/manage'); ?>">企业用户管理</a><?php if ($current_user->permission_id == 2): ?> |  <a href="<?php echo url('user/ContentManage'); ?>">企业内容审核员管理</a><?php endif; ?><?php if ($current_user->permission_id == 1): ?> | <a href="<?php echo url('user/AddManager'); ?>">电信管理员添加</a> | <a href="<?php echo url('user/tianyimanage'); ?>">电信管理员管理</a><?php endif; ?>	</span>



<form action="<?php echo url('user/AddMember'); ?>" method="post" name="mainform" enctype="multipart/form-data" 
        onsubmit="
        /*alert(this.username.value + this.userpasswd.value);
        alert(this.username.value.toString().length);
        return false;*/
        //alert(!isNaN(this.username.value));
        //alert(this.username.value.length == 11);
        if(this.username.value.toString().length == 0) 
        { 
            alert('请输入用户手机号码'); 
            return false; 
        }
        else 
        {
            if (isNaN(this.username.value.toString()))
            {
                alert('用户名必须是手机号码');
                return false;
            }
            if (this.username.value.toString().length != 11)
            {
                alert('手机号码长度为11位');
                return false;
            }    
            if (this.userpasswd.value.toString().length == 0) 
            { 
                alert('请输入用户密码'); 
                return false; 
            }
            return true; 
        }
        "
        >
        <table cellpadding="0" cellspacing="0" width="100%">
        <tbody class="">
        <tr>
                <td><span class="defaultbold">用户手机号码</span></td>
                <td><input class="input" type="text" value="" onBlur="" name="username" id="10011" size="36" /><span class="tip" name="tip"></span></td>
        </tr>

        <tr>
                <td><span class="defaultbold">用户IMSI号码</span></td>
                <td><input class="input" type="text" value="" onBlur="" name="user_phone_meid" id="10011" size="36" /><span class="tip" name="tip">可以为空</span></td>
        </tr>

        <tr>
                <td><span class="defaultbold">用户密码</span><br /></td>
                <td><input class="input" type="text" value="" name="userpasswd" onBlur="CheckPasswdIsNull()" id="10013" size="36" /><span class="error" name="warn_pass" style="display:none" id="10014">请输入用户密码</span></td>
        </tr>
        <tr>
            <td><span class="defaultbold">用户真名</span></td>
            <td><input class="input" type="text" value="" name="user_realname" id="10011" size="36" /></td>
	    </tr>
        <tr>
            <td><span class="defaultbold">用户办公室电话</span></td>
            <td><input class="input" type="text" value="" name="user_officetel" id="10011" size="36" /></td>
        </tr>

        <?php if ($current_user->permission_id == 1): ?>
        <tr>
                <td><span class="defaultbold">用户企业</span><br /></td>
            <td>
                <?php if ($enterprises_num > 1): ?>
                        <select name="userenterprise" >
                                <?php foreach ($enterprises as $enter): ?>
                                <?php if ($enter->enterprise_status == 1 && $enter->enterprise_id != 1): ?>
                                <option value="<?php echo $enter->id() ?>" id="<?php echo $enter->id() ?>" onclick="CheckSelectedID(<?php echo $enter->id() ?>)"><?php echo $enter->enterprise_name ?></option>
                                <?php endif; ?>
                                <?php endforeach; ?>
                        </select>
                <?php endif; ?>
                <span><a href="<?php echo url('enterprise/add'); ?>">增加企业</a></span>
                </td>
        </tr>
        <?php endif; ?>

<?php   //系统控制漏洞，后面必须修复 2011/11/22 
?>
        <?php if ($current_user->permission_id == 2): ?>
        <tr>
            <td><span class="defaultbold">用户部门</span><br /></td>
            <td>
                <select name="department_id" >
                    <option value="-1" id="-1" selected="">默认部门
                    <?php foreach ($deps as $col): ?>
                        <option value="<?php echo $col->id() ?>" id="<?php echo $col->id() ?>"><?php echo $col->department_name; ?>
                    </option>
                    <?php endforeach; ?>
                </select>
                <span><a href="<?php echo url('departments/add'); ?>">增加部门</a></span>
            </td>
        </tr>
        <tr>
                <td><span class="defaultbold">用户类型</span><br /></td>
                <td class="tbutton" colspan="6">
                <input type="radio" name="checktype"  value="3"/>&nbsp;内容审核员&nbsp;&nbsp;
                <input type="radio" name="checktype" value="4" checked="checked" />&nbsp;普通用户
        </td>
        </tr>
        <?php endif; ?>

        <tr>

                <td class="tbutton" colspan="6"><input type="submit" onclick="return(CheckFirst())" value="提交" class="btn" name="submit">&nbsp;
                <?php if ($current_user->permission_id == 2): ?>
                <span><a href="<?php echo url('user/batchadd'); ?>">批量录入</a></span>
                <span><a href="<?php echo url('user/ImportFromExcel'); ?>">从excel导入</a></span>
                
                <?php endif; ?>

                </td>
        </tr>
        </tbody>
        </table>
</form>

<script>
function   LTrim(str)           //   左空格 
{   
    var   i=0;  
    for(i=0;i <str.length;i++)   
    {   
        if(str.charAt(i)!= "   "&&str.charAt(i)!= "   ")break;
    }   
    str=str.substring(i,str.length);   
    return   str;   
}   
function   Trim(str)     //   两边空格 
{   
    return   LTrim(str);   
}  


function CheckNameIsNull()
{
    var name = document.getElementById("10011");
    if("" == name.value || Trim(name.value)== " ")
    {				
        var objSrc = document.getElementById("10012");
        objSrc.style.display = "";
    } 
    else
    {
        var objSrc = document.getElementById("10012");
        objSrc.style.display = "none";
    }
}

function CheckPasswdIsNull()
{
    var name = document.getElementById("10013");
    if("" == name.value || Trim(name.value)== " ")
    {				
        var objSrc = document.getElementById("10014");
        objSrc.style.display = "";
    } 
    else
    {
        var objSrc = document.getElementById("10014");
        objSrc.style.display = "none";
    }
}
function CheckFirst()
{
    var count=0;
    return true;
}
function CheckSelectedID(id)
{
    if(id == 1)
    {
        var objSrc = document.getElementById("2002");
        objSrc.style.display = "none";
    }
    else
    {
    }
}
</script>


<?php $this->_endblock(); ?>
